package practica4;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import weka.core.Instances;

public class LoadDataFile {

	public LoadDataFile(){}
	
	public Instances loadInstances(String pPath){
	 	
        // 1.2. Open the file
    FileReader fi=null;
	try {
		fi= new FileReader(pPath); 
	} catch (FileNotFoundException e) {
		System.out.println("ERROR: Revisar path del fichero de datos:"+pPath);
	}
	// 1.3. Load the instances
	Instances data=null;
	try {
		data = new Instances(fi);
	} catch (IOException e) {
		System.out.println("ERROR: Revisar contenido del fichero de datos: "+pPath);
	}
	// 1.4. Close the file
	try {
		fi.close();
	} catch (IOException e) {
		// TODO Auto-generated catch block
	}
	// 1.5. Shuffle the instances: apply Randomize filter
	//  HACER!!!!

	// 1.6. Specify which attribute will be used as the class: the last one, in this case 
	data.setClassIndex(data.numAttributes()-1);
	return data;
	
	}
}
